package com.wmx.thread.atomic.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**********************************
 * @author wmx
 * @date 2019/8/21 15:48
 * @description:
 * @version 1.0
 ************************************/
public class MyTryLock {
    private AtomicInteger atomicInteger = new AtomicInteger(0);

    private void getTryLock() throws GetLockException {
       boolean success = atomicInteger.compareAndSet(0,1);
       if (!success)
           throw new GetLockException("get lock fail");
    }


    private void unLock(){
        atomicInteger.compareAndSet(1,0);
    };
}
